home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / sun3.md / dbg.h < prev    next >
C/C++ Source or Header  |  1990-10-19  |  7KB  |  264 lines

  1. /*
  2.  * dbg.h --
  3.  *
  4.  *     Exported types and procedure headers for the debugger module.
  5.  *
  6.  * Copyright (C) 1985 Regents of the University of California
  7.  * All rights reserved.
  8.  *
  9.  *
  10.  * $Header: /sprite/src/kernel/dbg/sun3.md/RCS/dbg.h,v 9.4 90/10/09 11:50:52 jhh Exp $ SPRITE (Berkeley)
  11.  */
  12.  
  13. #ifndef _DBG
  14. #define _DBG
  15.  
  16. #ifndef _SPRITE
  17. #include <sprite.h>
  18. #endif
  19. #ifdef KERNEL
  20. #include <user/netInet.h>
  21. #include <netTypes.h>
  22. #else
  23. #include <netInet.h>
  24. #include <kernel/netTypes.h>
  25. #endif
  26.  
  27.  
  28. /*
  29.  * Variable to indicate that dbg wants a packet.
  30.  */
  31. extern    Boolean    dbg_UsingNetwork;
  32.  
  33. /*
  34.  * Variable that indicates that we are under control of the debugger.
  35.  */
  36. extern    Boolean    dbg_BeingDebugged;
  37.  
  38. /*
  39.  * The maximum stack address.
  40.  */
  41. extern    int    dbgMaxStackAddr;
  42.  
  43. /*
  44.  * Debugger using syslog to dump output of call command or not.
  45.  */
  46. extern    Boolean    dbg_UsingSyslog;
  47.  
  48. /*
  49.  * The different opcodes that kdbx can send us.
  50.  */
  51.  
  52. typedef enum {
  53.     DBG_READ_ALL_GPRS,        /* Read all 16 of the general purpose 
  54.                    registers */
  55.     DBG_WRITE_GPR,        /* Write one of the general purpose registers
  56.                    d0-d7 or a0-a7 */
  57.     DBG_CONTINUE,         /* Continue execution */
  58.     DBG_SINGLESTEP,        /* Single step execution */
  59.     DBG_DETACH,            /* The debugger has finished with the kernel */
  60.     DBG_INST_READ,        /* Read an instruction */
  61.     DBG_INST_WRITE,        /* Write an instruction */
  62.     DBG_DATA_READ,        /* Read data */
  63.     DBG_DATA_WRITE,        /* Write data */
  64.     DBG_SET_PID,        /* Set the process for which the stack 
  65.                  * back trace is to be done. */
  66.     DBG_GET_STOP_INFO,        /* Get all info needed by dbx after it stops. */
  67.     DBG_GET_VERSION_STRING,    /* Return the version string. */
  68.     DBG_DIVERT_SYSLOG,        /* Divert syslog output to the console. */
  69.     DBG_REBOOT,            /* Call the reboot routine. */
  70.     DBG_BEGIN_CALL,        /* Start a call. */
  71.     DBG_END_CALL,         /* Clean up after a call completes. */
  72.     DBG_CALL_FUNCTION,        /* Call a function. */
  73.     DBG_GET_DUMP_BOUNDS,    /* Get the bounds for the dump program. */
  74.     DBG_UNKNOWN            /* Used for error checking */
  75. } Dbg_Opcode;
  76.  
  77. typedef struct {
  78.     int    regNum;
  79.     int    regVal;
  80. } Dbg_WriteGPR;
  81.  
  82. typedef struct {
  83.     int        address;
  84.     int        numBytes;
  85.     char    buffer[100];
  86. } Dbg_WriteMem;
  87.  
  88. typedef Dbg_WriteMem Dbg_CallFunc;
  89.  
  90. typedef struct {
  91.     int        address;
  92.     int        numBytes;
  93. } Dbg_ReadMem;
  94.  
  95. typedef struct {
  96.     int        stringLength;
  97.     char    string[100];
  98. } Dbg_Reboot;
  99.  
  100. typedef enum {
  101.     DBG_SYSLOG_TO_ORIG,
  102.     DBG_SYSLOG_TO_CONSOLE,
  103. } Dbg_SyslogCmd;
  104.  
  105. typedef struct {
  106.     unsigned int    pageSize;
  107.     unsigned int    stackSize;
  108.     unsigned int    kernelCodeStart;
  109.     unsigned int    kernelCodeSize;
  110.     unsigned int    kernelDataStart;
  111.     unsigned int    kernelDataSize;
  112.     unsigned int    kernelStacksStart;
  113.     unsigned int    kernelStacksSize;
  114.     unsigned int    fileCacheStart;
  115.     unsigned int    fileCacheSize;
  116. } Dbg_DumpBounds;
  117.  
  118. /*
  119.  * Message format.
  120.  */
  121. typedef struct {
  122.     short    opcode;
  123.     union {
  124.     int        pid;
  125.     Dbg_WriteGPR    writeGPR;
  126.     Dbg_WriteMem    writeMem;
  127.     Dbg_CallFunc    callFunc;
  128.     Dbg_ReadMem    readMem;
  129.     int        pc;
  130.     Dbg_SyslogCmd    syslogCmd;
  131.     Dbg_Reboot    reboot;
  132.     } data;
  133. } Dbg_Msg;
  134.  
  135. #define    DBG_MAX_REPLY_SIZE    1400
  136. #define    DBG_MAX_REQUEST_SIZE    1400
  137.  
  138. /*
  139.  * The UDP port number that the kernel and kdbx use to identify a packet as
  140.  * a debugging packet.  (composed from "uc": 0x75 = u, 0x63 = c)
  141.  */
  142.  
  143. #define DBG_UDP_PORT     0x7563
  144.  
  145. /*
  146.  * The different statuses that we send kdbx after we stop.  There is one
  147.  * status for each exception.  These numbers matter because kdbx uses them to
  148.  * index an array.  Therefore don't change any of them without also changing
  149.  * kdbx's array in ../kdbx/machine.c.
  150.  *
  151.  *     DBG_INTERRUPT        No error just an interrupt from the console.
  152.  *     DBG_RESET        System reset.
  153.  *     DBG_BUS_ERROR        Bus error.
  154.  *     DBG_ADDRESS_ERROR    Address error.
  155.  *     DBG_ILLEGAL_INST        Illegal instruction.
  156.  *     DBG_ZERO_DIV        Division by zero.
  157.  *     DBG_CHK_INST        A CHK instruction failed.
  158.  *     DBG_TRAPV        Overflow trap.
  159.  *     DBG_PRIV_VIOLATION    Privledge violation.
  160.  *     DBG_TRACE_TRAP        Trace trap.
  161.  *     DBG_EMU1010        Emulator 1010 trap.
  162.  *     DBG_EMU1111        Emulator 1111 trap.
  163.  *     DBG_STACK_FMT_ERROR    Stack format error.
  164.  *     DBG_UNINIT_VECTOR    Unitiailized vector error.
  165.  *     DBG_SPURIOUS_INT        Spurious interrupt.
  166.  *     DBG_LEVEL1_INT        Level 1 interrupt.
  167.  *     DBG_LEVEL2_INT        Level 2 interrupt.
  168.  *     DBG_LEVEL3_INT        Level 3 interrupt.
  169.  *     DBG_LEVEL4_INT        Level 4 interrupt.
  170.  *     DBG_LEVEL5_INT        Level 5 interrupt.
  171.  *     DBG_LEVEL6_INT        Level 6 interrupt.
  172.  *     DBG_LEVEL7_INT        Level 7 interrupt.
  173.  *     DBG_SYSCALL_TRAP        A system call trap.
  174.  *     DBG_SIG_RET_TRAP        A return from signal trap.
  175.  *     DBG_BAD_TRAP        Bad trap.
  176.  *     DBG_BRKPT_TRAP        Breakpoint trap.
  177.  *     DBG_UKNOWN_EXC        Unknown exception.
  178.  */
  179.  
  180. #define DBG_INTERRUPT        0
  181. #define    DBG_RESET        1
  182. #define    DBG_BUS_ERROR        2
  183. #define    DBG_ADDRESS_ERROR    3
  184. #define    DBG_ILLEGAL_INST    4
  185. #define    DBG_ZERO_DIV        5
  186. #define    DBG_CHK_INST        6
  187. #define    DBG_TRAPV        7
  188. #define    DBG_PRIV_VIOLATION    8
  189. #define    DBG_TRACE_TRAP        9
  190. #define    DBG_EMU1010        10
  191. #define    DBG_EMU1111        11
  192. #define    DBG_STACK_FMT_ERROR    14
  193. #define    DBG_UNINIT_VECTOR    15
  194. #define    DBG_SPURIOUS_INT    24
  195. #define    DBG_LEVEL1_INT        25
  196. #define    DBG_LEVEL2_INT        26
  197. #define    DBG_LEVEL3_INT        27
  198. #define    DBG_LEVEL4_INT        28
  199. #define    DBG_LEVEL5_INT        29
  200. #define    DBG_LEVEL6_INT        30
  201. #define    DBG_LEVEL7_INT        31
  202. #define    DBG_SYSCALL_TRAP    33
  203. #define    DBG_SIG_RET_TRAP    34
  204. #define    DBG_BAD_TRAP        35
  205. #define    DBG_BRKPT_TRAP        47
  206.  
  207. #define DBG_FP_UNORDERED_COND  48
  208. #define DBG_FP_INEXACT_RESULT  49
  209. #define DBG_FP_ZERO_DIV        50
  210. #define DBG_FP_UNDERFLOW       51
  211. #define DBG_FP_OPERAND_ERROR   52
  212. #define DBG_FP_OVERFLOW        53
  213. #define DBG_FP_NAN             54
  214. #define    DBG_UNKNOWN_EXC           55
  215.  
  216. /*
  217.  * Variable that is set to true when we are called through the DBG_CALL macro.
  218.  */
  219. extern    Boolean    dbgPanic;
  220.  
  221. /* 
  222.  * Macro to call the debugger from kernel code.
  223.  */
  224. #define DBG_CALL    dbgPanic = TRUE; asm("trap #15");
  225.  
  226. /*
  227.  * Number of bytes between acknowledgements when the the kernel is writing
  228.  * to kdbx.
  229.  */
  230. #define DBG_ACK_SIZE    256
  231.  
  232. /*
  233.  * Info returned when GETSTOPINFO command is submitted.
  234.  */
  235. typedef struct {
  236.     int            codeStart;
  237.     int            maxStackAddr;
  238.     int            termReason;
  239.     int            trapCode;
  240.     unsigned    int    statusReg;
  241.     int            genRegs[16];
  242.     int            pc;
  243. } StopInfo;
  244.  
  245. extern    void    Dbg_Init _ARGS_((void));
  246. extern    void    Dbg_InputPacket _ARGS_((Net_Interface *interPtr,
  247.                     Address packetPtr, int packetLength));
  248. extern    Boolean    Dbg_InRange _ARGS_((unsigned int addr, int numBytes,
  249.                     Boolean writeable));
  250. extern Boolean
  251.     Dbg_ValidatePacket _ARGS_((int size, Net_IPHeader *ipPtr, int *lenPtr,
  252.                    Address *dataPtrPtr,
  253.                    Net_InetAddress *destIPAddrPtr,
  254.                    Net_InetAddress *srcIPAddrPtr,
  255.                    unsigned int *srcPortPtr));
  256. extern void
  257.     Dbg_FormatPacket _ARGS_((Net_InetAddress srcIPAddress,
  258.                  Net_InetAddress destIPAddress,
  259.                  unsigned int destPort, int dataSize,
  260.                  Address dataPtr));
  261. extern int    Dbg_PacketHdrSize _ARGS_((void));
  262.  
  263. #endif /*_DBG */
  264.